﻿using System;
using System.Threading;
using System.Threading.Tasks;

namespace Chapter1_14
{
    public static class Program
    {
        public static void Main(string[] args)
        {
            Task[] t = new Task[3];

            t[0] = Task.Run(() =>
            {
                Thread.Sleep(1000);
                Console.WriteLine("1");
            });

            t[1] = Task.Run(() => {
                Thread.Sleep(1000);
                Console.WriteLine("2");
            });

            t[2] = Task.Run(() => {
                Thread.Sleep(1000);
                Console.WriteLine("3");
            }); 

            Console.WriteLine("Esperando");
            Task.WaitAll(t);
            Console.WriteLine("Pronto");
            Console.ReadLine(); 
 
            
        }
    }
}
